package com.harry.resource.workflow.entity;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

import com.harry.basis.BasePoEntity;

import lombok.Getter;
import lombok.Setter;

import java.util.Set;

@Getter
@Setter
@Entity
public class WorkActivityInstance extends BasePoEntity {

	private static final long serialVersionUID = 1L;

	@Fetch(FetchMode.JOIN)
	@ManyToMany(cascade = CascadeType.DETACH, fetch = FetchType.LAZY)
	@JoinTable(joinColumns = @JoinColumn, inverseJoinColumns = @JoinColumn)
	private Set<com.harry.resource.inner.entity.InnerUser> users;

	@Fetch(FetchMode.JOIN)
	@OneToMany(cascade = CascadeType.REMOVE, fetch = FetchType.LAZY)
	@JoinColumn
	private Set<WorkActivityPropInstance> activityPropInstances;

	@Fetch(FetchMode.JOIN)
	@ManyToOne(cascade = CascadeType.DETACH, fetch = FetchType.LAZY)
	@JoinColumn(insertable = false, updatable = false)
	private WorkStateInstance stateInstance;

	@Fetch(FetchMode.JOIN)
	@ManyToOne(cascade = CascadeType.DETACH, fetch = FetchType.LAZY)
	@JoinColumn(nullable = false, updatable = false)
	private WorkActivityDefinition activityDefinition;
}
